<template>
	<view class="uni_box home">
		<view class="content">
			<view class="mone">
				<image class="mbg" src="/static/mine/mbg.png"></image>
				<view class="moneview">
					<view class="sehzhitwo" @click="getshezhi">
						<image class="shezhiicon" src="/static/mine/shezhi.png"></image>
					</view>
					<view class="touview">
						<image class="tou" :src="user.head_portrait?user.head_portrait:'/static/img/tou.png'"></image>
						<view class="ls" v-if="user.packageuser">
							<image class="icon_rz" :src="user.packageuser.logo"></image>
							<text>{{user.packageuser.name}}</text>
						</view>
					</view>
					<view class="nview">
						<view class="ntouone">
							<text class="name txt">{{user.nickname}}</text>
							<!-- <image class="mvip" src="/static/mine/mvip.png"></image> -->
							<!-- <view class="sehzhi" @click="getshezhi">
								<image class="shezhiicon" src="/static/mine/shezhi.png"></image>
							</view> -->
						</view>
						<text class="hui">会员ID:{{user.id}}</text>
					</view>
					
				</view>
			</view>
			<view class="mtwo">
				<view class="ming" @click="getmingxi">
					<image class="icon_mx" src="/static/mine/icon_mx.png"></image>
					<text>明细</text>
				</view>
				<view class="zhangone" @click="iseye=!iseye">
					<text class="zyu">账户余额</text>
					<image class="yan" src="/static/mine/yan.png" v-if="!iseye"></image>
					<image class="yan" src="/static/mine/yans.png" v-if="iseye"></image>
				</view>
				<!-- <view class="zhangtwo">
					<text class="pjia">¥<text class="jianum" :class="!iseye?'feieye':''">{{ iseye?user.balance:'***'||0 }}</text></text>
				</view> -->
				<view class="tiview">
					<view class="tiitem">
						<text class="tinum">{{ iseye?user.balance:'***'||0 }}</text>
						<text class="tishou">账户余额(元)</text>
					</view>
					<view class="tiline"></view>
					<view class="tiitem">
						<text class="tinum">{{ iseye?info.bouns_today:'***'||0 }}</text>
						<text class="tishou">今日收益(元)</text>
					</view>
					<view class="tiline"></view>
					<view class="tiitem">
						<text class="tinum">{{ iseye?info.bouns_all:'***'||0 }}</text>
						<text class="tishou">总收益(元)</text>
					</view>
				</view>
			</view>
			<view class="mthree">
				<text class="fugong">服务工具</text>
				<view class="glist">
					<view class="gitem" v-for="(item,index) in monelist" :key="index" @click="mClick(item)">
						<image class="micon" :src="item.img"></image>
						<text>{{item.name}}</text>
					</view>
				</view>
			</view>
			<view class="tuichu" @click="gettui">退出登录</view>
		</view>

		<!-- 兑换弹窗 -->
		<view class="yhupopview">
			<u-popup v-model="tanshow" mode="center" @close="popclose(3)" width="82%" :closeable="true" z-index="1000">
				<view class="yhpop">

					<text class="yhtit">
						请输入兑换码
					</text>
					<view class="pinput">
						<u-input v-model="card_no" type="text" :border="false" placeholder="请输入"/>
					</view>
					<view class="quxiaoview">
						<view class="popquview" @click="popclose(3)">取消</view>
						<view class="popquview quebtn" @click="popka(3)">确认</view>
					</view>
				</view>
			</u-popup>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				monelist:[
					{id:1,name:'分享好友',img:'/static/mine/mone.png'},
					{id:2,name:'合同下载',img:'/static/mine/mtwo.png'},
					{id:3,name:'我的代理',img:'/static/mine/mthree.png'},
					{id:4,name:'我的订单',img:'/static/mine/mfour.png'},
					{id:5,name:'报名记录',img:'/static/mine/mfive.png'},
					{id:6,name:'历史成绩',img:'/static/mine/msix.png'},
					{id:7,name:'战略合作',img:'/static/mine/mseven.png'},
					{id:8,name:'卡密兑换',img:'/static/mine/meight.png'}
				],
				tanshow:false,
				value:'',
				info:{},
				user:{},
				iseye:true,
				card_no:''
			}
		},
		onLoad() {
			
		},
		onShow() {
			this.getuserinfo();
		},
		methods: {
			async getuserinfo(){
				let res = await this.$u.api.userinfo({
				});
				this.info = res
				this.user = res.user
			},
			mClick(item){
				let id = item.id
				if(id == 1){
					//分享
					this.navrouter("/pages/TPage/Share");
				}else if(id == 2){
					//合同下载
					this.navrouter("/pages/TPage/HeTongDown");
				}else if(id == 3){
					//我的委托
					this.navrouter("/pages/TPage/MyWeituo");
				}else if(id == 4){
					//我的订单 MyOrder
					this.navrouter("/pages/TPage/MyOrder");
				}else if(id == 5){
					//报名记录
					this.navrouter("/pages/TPage/BaoRecord");
				}else if(id == 6){
					//历史成绩
					this.navrouter("/pages/TPage/HisChengji");
				}else if(id == 7){
					//合作加盟
					this.navrouter("/pages/TPage/HezuoJiameng");
				}else if(id == 8){
					//兑换码
					this.tanshow = true
					// this.navrouter("/pages/TPage/FaPiaoManage");
				}
			},
			getshezhi(){
				this.navrouter("/pages/TPage/Ziliao");
			},
			gettui(){
				//退出登陆
				let that = this
				uni.showModal({
					title: '提示',
					content: '确定退出登录？',
					cancelText: "取消", // 取消按钮的文字  
					confirmText: "确认", // 确认按钮的文字  
					// showCancel: false, // 是否显示取消按钮，默认为 true
					// confirmColor: '#f55850',
					// cancelColor: '#39B54A',
					success: (res) => {
					if(res.confirm) {  
						uni.clearStorageSync();
						that.$store.commit('outLogin');
						that.$u.toast('退出成功');
						setTimeout(() => {
							uni.redirectTo({
								url: '/pages/login/login'
							})
						}, 1000);
					} else {  
						console.log('cancel') //点击取消之后执行的代码
						}  
					} 
				})
			},
			getmingxi(){
				this.navrouter("/pages/TPage/MingXi");
			},
			popclose(){
				this.card_no = ''
				this.tanshow = false
			},
			async popka(){
				let res = await this.$u.api.kaexchange({
					card_no:this.card_no
				});
				this.$u.toast("操作成功");

				this.card_no = ''
				this.popclose()
				this.getuserinfo();
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #F5F5F5;
	}
	.content{
		background-color: #F5F5F5;
		padding-bottom: 140rpx;
		.mone{
			height: 500rpx;
			position: relative;
			.mbg{
				position: absolute;
				width: 100%;
				height: 100%;
			}
			.moneview{
				position: relative;
				width: 100%;
				padding: 70rpx 30rpx 30rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				.sehzhitwo{
					margin-left: auto;
					position: absolute;
					right: 30rpx;
					top: 30rpx;
					width: 68rpx;
					height: 68rpx;
					background: rgba(255,255,255,0.5);
					border-radius: 20rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					.shezhiicon{
						width: 44rpx;
						height: 44rpx;
					}
				}
				.touview{
					width: 150rpx;
					height: 150rpx;
					position: relative;
					display: flex;
					align-items: center;
					justify-content: center;
					.tou{
						position: absolute;
						width: 100%;
						height: 100%;
						border-radius: 50%;
					}
					.ls{
						position: absolute;
						bottom: -10rpx;
						z-index: 1;
						padding: 6rpx 12rpx;
						background: #ECF2FE;
						border-radius: 5rpx;
						display: flex;
						align-items: center;
						.icon_rz{
							width: 28rpx;
							height: 28rpx;
							margin-right: 6rpx;
						}
						text{
							font-family: PingFang SC;
							font-weight: 500;
							font-size: 20rpx;
							color: #3E65E5;
						}
					}
				}
				.nview{
					display: flex;
					flex: 1;
					flex-direction: column;
					margin-left: 30rpx;
					.ntouone{
						display: flex;
						flex-direction: row;
						align-items: center;
						.name{
							font-family: PingFang SC;
							font-weight: bold;
							font-size: 50rpx;
							color: #111111;
							max-width: 80%;
							display: inline-block;
						}
						.mvip{
							width: 70rpx;
							height: 40rpx;
							margin-left: 10rpx;
						}

						.sehzhi{
							margin-left: auto;
							width: 68rpx;
							height: 68rpx;
							background: rgba(255,255,255,0.5);
							border-radius: 20rpx;
							display: flex;
							align-items: center;
							justify-content: center;
							.shezhiicon{
								width: 44rpx;
								height: 44rpx;
							}
						}
					}
					.hui{
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #666666;
						display: block;
						margin-top: 15rpx;
					}
				}
			}
		}
		.mtwo{
			margin: -200rpx 30rpx 30rpx;
			position: relative;
			background: #FFFFFF;
			border-radius: 20rpx;
			padding: 30rpx;
			.ming{
				position: absolute;
				top: 40rpx;
				right: 0;
				width: 130rpx;
				height: 44rpx;
				background: #E6EEFD;
				border-radius: 22rpx 0rpx 0rpx 22rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				.icon_mx{
					width: 28rpx;
					height: 28rpx;
					margin-right: 14rpx;
				}
				text{
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #3E65E5;
				}
			}
			.zhangone{
				display: flex;
				flex-direction: row;
				align-items: center;
				.zyu{
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #999999;
				}
				.yan{
					margin-left: 20rpx;
					width: 30rpx;
					height: 30rpx;
				}
			}
			.zhangtwo{
				margin-top: 24rpx;
				.pjia{
					font-family: Adobe Heiti Std;
					font-weight: normal;
					font-size: 28rpx;
					color: #333333;
				}
				.jianum{
					font-family: DIN;
					font-weight: bold;
					font-size: 60rpx;
					color: #333333;
					display: inline-block;
					margin-left: 5rpx;
				}
				.feieye{
					position: relative;
					top: 18rpx;
				}
			}
			.tiview{
				display: flex;
				flex-direction: row;
				margin-top: 40rpx;
				align-items: center;
				.tiitem{
					width: 33%;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					// height: 30rpx;
					// border-right: 1rpx solid #CCCCCC;
					.tinum{
						font-family: DIN;
						font-weight: 500;
						font-size: 32rpx;
						color: #333333;
					}
					.tishou{
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #999999;
						display: block;
						margin-top: 13rpx;
					}
				}
				.tiline{
					height: 30rpx;
					width: 1rpx;
					background-color: #ccc;
				}
			}
		}
		.mthree{
			padding: 30rpx 30rpx 0;
			background: #FFFFFF;
			border-radius: 20rpx;
			margin: 0 30rpx 30rpx;
			.fugong{
				font-family: Source Han Sans CN;
				font-weight: bold;
				font-size: 32rpx;
				color: #333333;
				display: block;
				margin-bottom: 40rpx;
			}
			.glist{
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				.gitem{
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					width: 25%;
					margin-bottom: 40rpx;
					.micon{
						margin-bottom: 10rpx;
						width: 60rpx;
						height: 60rpx;
					}
					text{
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #333333;
					}
				}
			}
		}
		.tuichu{
			margin: 40rpx 30rpx;
			height: 88rpx;
			border-radius: 20rpx;
			border: 1px solid #999999;
			display: flex;
			align-items: center;
			justify-content: center;
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #666666;
		}
	}
	.yhupopview{
		/deep/.u-mode-center-box{
			background-color: transparent;
		}
		.yhpop{
			border-radius: 24rpx;
			padding: 40rpx;
			background-color: #fff;
			.yhtit{
				display: block;
				text-align: center;
				font-family: PingFang SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #333333;
				margin-bottom: 45rpx;
			}
			.pinput{
				background: #F5F5F5;
				border-radius: 10rpx;
				padding:10rpx 20rpx;
				margin-bottom: 20rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
			}
			.huoqu{
				margin-left: 20rpx;
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #496EE7;
			}
			.quxiaoview{
				display: flex;
				flex-direction: row;
				margin-top: 40rpx;
				justify-content: space-between;
				width: 100%;
				.popquview{
					height: 68rpx;
					border-radius: 10rpx;
					border: 1rpx solid #111111;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 48%;
				}
				.quebtn{
					background: #496EE7;
					color: #fff;
					border: 1rpx solid #496EE7;
				}
			}
		}
	}
</style>
